/**
 * @ClassName: UserOrderService
 * @author linsen
 * @date 2016-10-23
 */
package com.fzrskj.cloud.free.user.service;

import com.fzrskj.cloud.free.consts.CConsts;
import com.fzrskj.cloud.free.core.enums.DicParamEnum;
import com.fzrskj.cloud.free.core.tool.CSessionTool;
import com.fzrskj.cloud.free.core.utils.CloudContextUtils;
import com.fzrskj.cloud.free.dic.utils.DicParamUtils;
import com.fzrskj.cloud.free.user.bean.UserAccount;
import com.fzrskj.cloud.free.user.bean.UserAccountView;
import com.fzrskj.cloud.free.user.bean.UserOrder;
import com.fzrskj.cloud.free.user.bean.UserOrderView;
import com.fzrskj.cloud.free.user.bean.statistics.Statistics;
import com.fzrskj.cloud.free.user.tool.StatistisTool;
import com.fzrskj.cloud.free.user.utils.FuncHandleUtils;
import com.fzrskj.cloud.free.user.utils.UserAccountUtils;
import com.fzrskj.cloud.free.user.utils.UserOrderUtils;
import com.fzrskj.cloud.free.user.utils.finance.OrderFinanceUtils;
import ms.core.consts.SysErr;
import ms.core.object.CObject;
import ms.core.tool.DateTimeTool;
import ms.core.tool.JsonTool;
import ms.core.tool.StrTool;
import ms.core.tool.XmlCodeParser;
import net.sf.json.JSONObject;
import org.apache.commons.collections.map.HashedMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class UserOrderService extends CObject {

    /**
     * 查询订单列表(会员)
     *
     * @param request
     * @param response
     * @param p={"orderId":"订单编号","orderType":"订单类型","productClass":"产品类型","payStatus":"支付状态","handleStatus":"处理状态","userName":"会员名","start":"开始时间","end":"结束时间"}
     * @param sid
     * @return
     */
    public String queryUserOrder(HttpServletRequest request, HttpServletResponse response, String p, String sid) {
        int uid = CloudContextUtils.getSession().getUID();

        String orderIds = JsonTool.getStrValue(p, "orderId", null);
        String orderType = JsonTool.getStrValue(p, "orderType", null);
        String productClass = JsonTool.getStrValue(p, "productClass", null);
        String payStatus = JsonTool.getStrValue(p, "payStatus", null);
        String handleStatus = JsonTool.getStrValue(p, "handleStatus", null);
        String start = JsonTool.getStrValue(p, "start", null);
        String end = JsonTool.getStrValue(p, "end", null);
        int page = JsonTool.getIntValue(p, "page", 1);
        int pagesize = JsonTool.getIntValue(p, "pagesize", CConsts.PAGE_SIZE);

        Map<String, Object> map = new HashMap<String, Object>();
        if (!StrTool.isBlankStr(orderIds)) {
            map.put("orderId", orderIds);
        }
        if (!StrTool.isBlankStr(orderType)) {
            map.put("orderType", orderType);
        }
        if (!StrTool.isBlankStr(productClass)) {
            map.put("productClass", productClass);
        }
        if (!StrTool.isBlankStr(payStatus)) {
            map.put("payStatus", payStatus);
        }
        if (!StrTool.isBlankStr(handleStatus)) {
            map.put("handleStatus", handleStatus);
        }
        if (!StrTool.isBlankStr(start)) {
            Date starts = DateTimeTool.strToDate(start);
            map.put("start", starts);
        }
        if (!StrTool.isBlankStr(end)) {
            Date ends = DateTimeTool.strToDate(end);
            map.put("end", DateTimeTool.incDay(ends, 1));
        }
        map.put("userId", uid);

        UserOrderUtils obj = new UserOrderUtils();
        int rows = obj.queryUserOrderCount(map);
        String code = obj.getErrCode();

        if (!code.equals(SysErr.CODE_SUCCESS)) {
            return XmlCodeParser.formatResultTips(false, code);
        }
        if (rows < (page - 1) * pagesize) {
            return XmlCodeParser.formatResultTips(false, SysErr.SYS_DATA_NOT_FOUND);
        }
        int pages = Math.round((rows + pagesize - 1) / pagesize);
        List<UserOrderView> list = obj.queryUserOrderViewList(map, page, pagesize);
        code = obj.getErrCode();
        obj.dispose();
        if (!code.equals(SysErr.CODE_SUCCESS)) {
            return XmlCodeParser.formatCustomTips(false, code);
        }
        //JSON数据
        String data = JsonTool.listBeanToJson(list);
        return XmlCodeParser.formatResultPageData(code, page, pages, pagesize, rows, data);
    }

    /**
     * 查询订单列表(管理员)
     *
     * @param request
     * @param response
     * @param p={"orderId":"订单编号","orderType":"订单类型","productClass":"产品类型","payStatus":"支付状态","handleStatus":"处理状态","userName":"会员名","start":"开始时间","end":"结束时间"}
     * @param sid
     * @return
     */
    public String queryAdminOrder(HttpServletRequest request, HttpServletResponse response, String p, String sid) {
        String userName = JsonTool.getStrValue(p, "userName", null);
        String orderId = JsonTool.getStrValue(p, "orderId", null);
        String orderType = JsonTool.getStrValue(p, "orderType", null);
        String productClass = JsonTool.getStrValue(p, "productClass", null);
        String payStatus = JsonTool.getStrValue(p, "payStatus", null);
        String handleStatus = JsonTool.getStrValue(p, "handleStatus", null);
        String orderParam = JsonTool.getStrValue(p, "orderParam", null);
        String start = JsonTool.getStrValue(p, "start", null);
        String end = JsonTool.getStrValue(p, "end", null);
        String remark = JsonTool.getStrValue(p, "remark", null);
        int page = JsonTool.getIntValue(p, "page", 1);
        int pagesize = JsonTool.getIntValue(p, "pagesize", CConsts.PAGE_SIZE);

        Map<String, Object> map = new HashMap<String, Object>();
        if (!StrTool.isBlankStr(userName)) {
            map.put("userName", userName);
        }
        if (!StrTool.isBlankStr(orderId)) {
            map.put("orderId", orderId);
        }
        if (!StrTool.isBlankStr(orderType)) {
            map.put("orderType", orderType);
        }
        if (!StrTool.isBlankStr(productClass)) {
            map.put("productClass", productClass);
        }
        if (!StrTool.isBlankStr(payStatus)) {
            map.put("payStatus", payStatus);
        }
        if (!StrTool.isBlankStr(handleStatus)) {
            map.put("handleStatus", handleStatus);
        }
        if (!StrTool.isBlankStr(orderParam)) {
            map.put("orderParam", orderParam);
        }
        if (!StrTool.isBlankStr(start)) {
            Date starts = DateTimeTool.strToDate(start);
            map.put("start", starts);
        }
        if (!StrTool.isBlankStr(end)) {
            Date ends = DateTimeTool.strToDate(end);
            map.put("end", DateTimeTool.incDay(ends, 1));
        }
        if (!StrTool.isBlankStr(remark)) {
            map.put("remark", remark);
        }
        UserOrderUtils obj = new UserOrderUtils();
        int rows = obj.queryUserOrderCount(map);
        String code = obj.getErrCode();

        if (!code.equals(SysErr.CODE_SUCCESS)) {
            return XmlCodeParser.formatResultTips(false, code);
        }
        if (rows < (page - 1) * pagesize) {
            return XmlCodeParser.formatResultTips(false, SysErr.SYS_DATA_NOT_FOUND);
        }
        int pages = Math.round((rows + pagesize - 1) / pagesize);
        List<UserOrderView> list = obj.queryUserOrderViewList(map, page, pagesize);
        code = obj.getErrCode();
        obj.dispose();
        if (!code.equals(SysErr.CODE_SUCCESS)) {
            return XmlCodeParser.formatCustomTips(false, code);
        }
        //JSON数据
        String data = JsonTool.listBeanToJson(list);
        return XmlCodeParser.formatResultPageData(code, page, pages, pagesize, rows, data);
    }

    public String adminOrderRemark (HttpServletRequest request, HttpServletResponse response, String p, String sid) {
        Integer id = JsonTool.getIntValue(p,"id", 0);
        String remark = JsonTool.getStrValue(p, "remark", "");

        if (id < 1 || StrTool.isBlankStr(remark)) {
            return XmlCodeParser.formatResultTips(false, SysErr.SYS_PARAM_ERR);
        }

        UserOrderUtils orderUtils = new UserOrderUtils();
        Map<String, Object> update = new HashedMap();
        update.put("remark", remark);

        Map<String, Object> cdt = new HashedMap();
        cdt.put("id", id);
        orderUtils.modUserOrder(update, cdt);

        return XmlCodeParser.formatResultTips(true, SysErr.CODE_SUCCESS);
    }

    /**
     * 删除订单(会员)
     *
     * @param request
     * @param response
     * @param p={"orderId":"orderId"}
     * @param sid
     * @return
     */
    public String delUserOrder(HttpServletRequest request, HttpServletResponse response, String p, String sid) {
        int uid = CloudContextUtils.getSession().getUID();
        int uType = CSessionTool.getAccountTypeCloud(sid);

        String orderId = JsonTool.getStrValue(p, "orderId", "");
        Map<String, Object> cdt = new HashMap<String, Object>();
            if (uType > 0) {
            cdt.put("userId", uid);
        }
        cdt.put("orderId", orderId);

        UserOrderUtils utils = new UserOrderUtils();
        UserOrder userOrder = utils.getUserOrder(orderId);
        if (!("N".equals(userOrder.getPayStatus()) && "N".equals(userOrder.getHandleStatus()))) {
            return XmlCodeParser.formatResultTips(false, "ORDER NOT ALLOWED DELETE", " 订单已付款或已处理，不允许取消");
        }

        int ret = utils.delUserOrder(cdt);
        if (ret < 1) {
            return XmlCodeParser.formatResultTips(false, "ORDER NOT EXISTS", "订单不存在或已不可用");
        }
        String code = utils.getErrCode();
        return XmlCodeParser.formatResultTips(true, code);
    }

    /**
     * 删除订单(管理员)
     *
     * @param request
     * @param response
     * @param p={"orderId":"orderId"}
     * @param sid
     * @return
     */
    public String adminDelOrder(HttpServletRequest request, HttpServletResponse response, String p, String sid) {
        String orderId = JsonTool.getStrValue(p, "orderId", "");
        Integer type = JsonTool.getIntValue(p, "type", 1);
        Map<String, Object> cdt = new HashMap<String, Object>();
        cdt.put("orderId", orderId);

        //先处理退款
        if (type == 2) {
            OrderFinanceUtils financeUtils = new OrderFinanceUtils();
            Boolean flag = financeUtils.deleteOrder(orderId);
            if (!flag) {
                return XmlCodeParser.formatCustomTips(false, financeUtils.getErrCode(), financeUtils.getMsg());
            }
        }

        UserOrderUtils utils = new UserOrderUtils();
        int ret = utils.delUserOrder(cdt);
        String code = utils.getErrCode();
        return XmlCodeParser.formatResultTips(ret > 0, code);
    }

    /**
     * 获取订单详情
     *
     * @param request
     * @param response
     * @param p={"orderId":"orderId"}
     * @param sid
     * @return
     */
    public String getUserOrderInfo(HttpServletRequest request, HttpServletResponse response, String p, String sid) {
        String orderId = JsonTool.getStrValue(p, "orderId", null);
        if (StrTool.isBlankStr(orderId)) {
            return XmlCodeParser.formatResultTips(false, SysErr.SYS_PARAM_ERR);
        }
        UserOrderUtils utils = new UserOrderUtils();
        //获取订单数据
        UserOrderView userOrder = utils.getUserOrderView(orderId);
        if (null == userOrder) {
            return XmlCodeParser.formatResultTips(false, "ORDER NOT EXISTS", "订单不存在或已不可用");
        }
        String code = utils.getErrCode();
        //关闭utils
        utils.dispose();
        if (!code.equals(SysErr.CODE_SUCCESS)) {
            return XmlCodeParser.formatResultTips(false, code);
        }

        return XmlCodeParser.formatResultData(true, SysErr.CODE_SUCCESS, JsonTool.beanToJson(userOrder));
    }

    /**
     * 添加订单
     *
     * @param request
     * @param response
     * @param p={"cartNos":"cartNos"}
     * @param sid
     * @return
     */
    public String addUserOrder(HttpServletRequest request, HttpServletResponse response, String p, String sid) {
        int uid = CloudContextUtils.getSession().getUID();

        String cartNos = JsonTool.getStrValue(p, "cartNos", "");
        if (StrTool.isBlankStr(cartNos)) {
            return XmlCodeParser.formatResultTips(false, SysErr.SYS_PARAM_ERR);
        }

        //检查会员实名状态
        if ("Y".equals(DicParamUtils.getParamValue(DicParamEnum.MUST_REAL_NAME.getVal()))) {
            UserAccountView userAccount = UserAccountUtils.getUserAccountView(uid);
            if (null == userAccount) {
                return XmlCodeParser.formatResultTips(false, "MUST REAL NAME", "您还未登录或者使用的是管理账号");
            }
            if (3 != userAccount.getIsCertified()) {
                return XmlCodeParser.formatResultTips(false, "MUST REAL NAME", "您的账号还未通过实名认证，无法下单开展新业务");
            }
        }

        UserOrderUtils utils = new UserOrderUtils();
        String orderIds = utils.addUserOrder(uid, cartNos);
        String code = utils.getErrCode();
        if (!code.equals(SysErr.CODE_SUCCESS)) {
            return XmlCodeParser.formatResultTips(false, code);
        }

        JSONObject json = new JSONObject();
        json.put("orderIds", orderIds);
        return XmlCodeParser.formatResultData(true, SysErr.CODE_SUCCESS, json.toString());
    }

    /**
     * 会员获取订单(指定订单号)
     *
     * @param request
     * @param response
     * @param p={"orderIds":"orderIds"}
     * @param sid
     * @return
     */
    public String getUserOrderList(HttpServletRequest request, HttpServletResponse response, String p, String sid) {
        int uid = CloudContextUtils.getSession().getUID();

        String orderIds = JsonTool.getStrValue(p, "orderIds", "");
        if (orderIds == null) {
            orderIds = "";
        }
        if (StrTool.isBlankStr(orderIds)) {
            return XmlCodeParser.formatResultTips(false, SysErr.SYS_PARAM_ERR);
        }

        UserOrderUtils utils = new UserOrderUtils();
        List<UserOrderView> list = utils.getUserOrderList(uid, orderIds);
        String code = utils.getErrCode();
        if (!code.equals(SysErr.CODE_SUCCESS)) {
            return XmlCodeParser.formatResultTips(false, code);
        }

        return XmlCodeParser.formatResultData(true, SysErr.CODE_SUCCESS, JsonTool.listBeanToJson(list));
    }

    /**
     * 管理员获取订单(指定订单号)
     *
     * @param request
     * @param response
     * @param p={"orderIds":"orderIds"}
     * @param sid
     * @return
     */
    public String getAdminOrderList(HttpServletRequest request, HttpServletResponse response, String p, String sid) {
        String orderIds = JsonTool.getStrValue(p, "orderIds", "");
        if (orderIds == null) {
            orderIds = "";
        }
        if (StrTool.isBlankStr(orderIds)) {
            return XmlCodeParser.formatResultTips(false, SysErr.SYS_PARAM_ERR);
        }

        UserOrderUtils utils = new UserOrderUtils();
        List<UserOrderView> list = utils.getUserOrderList(0, orderIds);
        String code = utils.getErrCode();
        if (!code.equals(SysErr.CODE_SUCCESS)) {
            return XmlCodeParser.formatResultTips(false, code);
        }

        return XmlCodeParser.formatResultData(true, SysErr.CODE_SUCCESS, JsonTool.listBeanToJson(list));
    }

    /**
     * 获取待支付订单
     *
     * @param request
     * @param response
     * @param p={"orderIds":"orderIds"}
     * @param sid
     * @return
     */
    public String getPayUserOrder(HttpServletRequest request, HttpServletResponse response, String p, String sid) {
        int uid = CloudContextUtils.getSession().getUID();
        String orderIds = JsonTool.getStrValue(p, "orderIds", "");
        if (orderIds == null) {
            orderIds = "";
        }
        if (StrTool.isBlankStr(orderIds)) {
            return XmlCodeParser.formatResultTips(false, SysErr.SYS_PARAM_ERR);
        }

        UserOrderUtils utils = new UserOrderUtils();
        List<UserOrderView> list = utils.getUserOrderList(uid, orderIds);
        String code = utils.getErrCode();
        if (!code.equals(SysErr.CODE_SUCCESS)) {
            return XmlCodeParser.formatResultTips(false, code);
        }

        //订单价格
        double payPrice = 0;
        if (list != null) {
            for (UserOrderView uo : list) {
                payPrice += uo.getPayAmount();
            }
        }

        //会员信息
        UserAccountUtils uaUtils = new UserAccountUtils();
        UserAccount userAccount = uaUtils.queryAccountByName(CSessionTool.getAccountCloud(sid));

        String data = String.format("{\"list\":%s,\"payPrice\":%s,\"userAccount\":%s}", JsonTool.listBeanToJson(list), payPrice, JsonTool.beanToJson(userAccount));
        return XmlCodeParser.formatResultData(true, SysErr.CODE_SUCCESS, data);
    }

    /**
     * 处理订单
     *
     * @param request
     * @param response
     * @param p={"orderId":"orderId"}
     * @param sid
     * @return
     */
    public String handleOrder(HttpServletRequest request, HttpServletResponse response, String p, String sid) {
        String orderId = JsonTool.getStrValue(p, "orderId", "");
        if (StrTool.isBlankStr(orderId)) {
            return XmlCodeParser.formatResultTips(false, SysErr.SYS_PARAM_ERR);
        }

        FuncHandleUtils utils = new FuncHandleUtils();
        String data = utils.HandleOnLine(orderId);
        return XmlCodeParser.formatResultData(true, SysErr.CODE_SUCCESS, data);
    }

    private String modOrder(HttpServletRequest req, HttpServletResponse resp, String p, String sid, Boolean isAdmin) {
        int uid = CSessionTool.getUidCloud(sid);
        if (uid <= 0) {
            return XmlCodeParser.formatResultTips(false, SysErr.USER_NOT_LOGIN);
        }
        String userName = CSessionTool.getAccountCloud(sid);
        String orderid = JsonTool.getStrValue(p, "orderid", "");
        String orderparam = JsonTool.getStrValue(p, "orderparam", "");
        Map<String, Object> values = new HashMap<String, Object>();
        values.put("orderparam", orderparam);
        Map<String, Object> cdt = new HashMap<String, Object>();
        cdt.put("orderid", orderid);
        if (!isAdmin) {
            cdt.put("username", userName);
        }
        UserOrderUtils obj = new UserOrderUtils();
        int ret = obj.modUserOrder(values, cdt);
        obj.dispose();
        String code = obj.getErrCode();
        return XmlCodeParser.formatResultTips(ret > 0, code);
    }

    /**
     * 处理中订单改为未处理
     *
     * @param req
     * @param resp
     * @param p
     * @param sid
     * @return
     */
    public String modOrderStatusAdmin(HttpServletRequest req, HttpServletResponse resp, String p, String sid) {
        int uid = CSessionTool.getUidCloud(sid);
        if (uid <= 0) {
            return XmlCodeParser.formatResultTips(false, SysErr.USER_NOT_LOGIN);
        }
        String orderid = JsonTool.getStrValue(p, "orderid", "");
        Map<String, Object> values = new HashMap<>();
        values.put("handleStatus", "N");
        Map<String, Object> cdt = new HashMap<>();
        cdt.put("orderid", orderid);
        cdt.put("handleStatus", "C");
        UserOrderUtils obj = new UserOrderUtils();
        int ret = obj.modUserOrder(values, cdt);
        obj.dispose();
        String code = obj.getErrCode();
        return XmlCodeParser.formatResultTips(ret > 0, code);
    }

    /**
     * 会员修改订单信息
     *
     * @param req
     * @param resp
     * @param p
     * @param sid
     * @return
     */
    public String modOrderDataUser(HttpServletRequest req, HttpServletResponse resp, String p, String sid) {
        return modOrder(req, resp, p, sid, false);
    }

    /**
     * 会员修改订单信息
     *
     * @param req
     * @param resp
     * @param p
     * @param sid
     * @return
     */
    public String modOrderDataAdmin(HttpServletRequest req, HttpServletResponse resp, String p, String sid) {
        return modOrder(req, resp, p, sid, true);
    }

    /**
     * 管理员修改订单状态
     *
     * @param req
     * @param resp
     * @param p
     * @param sid
     * @return
     */
    public String modUserOrderAdmin(HttpServletRequest req, HttpServletResponse resp, String p, String sid) {
        String orderId = JsonTool.getStrValue(p, "orderId", "");
        UserOrderUtils obj = new UserOrderUtils();
        UserOrder userOrderData = new UserOrder();
        userOrderData.setOrderId(orderId);
        userOrderData.setHandleStatus("Y");
        int ret = obj.modUserOrder(userOrderData);
        obj.dispose();
        String code = obj.getErrCode();
        return XmlCodeParser.formatResultTips(ret > 0, code);
    }

    /**
     * 统计订单
     *
     * @param req
     * @param resp
     * @param p={"orderType":"订单类型","productClass":"产品类型","payStatus":"支付状态","handleStatus":"处理状态","userName":"会员名","start":"开始时间","end":"结束时间"}
     * @param sid
     * @return
     */
    public String queryUserOrderCount(HttpServletRequest req, HttpServletResponse resp, String p, String sid) {
        String orderType = JsonTool.getStrValue(p, "orderType", null);
        String productClass = JsonTool.getStrValue(p, "productClass", null);
        String payStatus = JsonTool.getStrValue(p, "payStatus", null);
        String handleStatus = JsonTool.getStrValue(p, "handleStatus", null);
        String start = JsonTool.getStrValue(p, "start", null);
        String end = JsonTool.getStrValue(p, "end", null);

        Map<String, Object> map = new HashMap<String, Object>();
        if (!StrTool.isBlankStr(orderType)) {
            map.put("orderType", orderType);
        }
        if (!StrTool.isBlankStr(productClass)) {
            map.put("productClass", productClass);
        }
        if (!StrTool.isBlankStr(payStatus)) {
            map.put("payStatus", payStatus);
        }
        if (!StrTool.isBlankStr(handleStatus)) {
            map.put("handleStatus", handleStatus);
        }
        if (!StrTool.isBlankStr(start)) {
            Date starts = DateTimeTool.strToDate(start);
            map.put("start", starts);
        }
        if (!StrTool.isBlankStr(end)) {
            Date ends = DateTimeTool.strToDate(end);
            map.put("end", DateTimeTool.incDay(ends, 1));
        }
        UserOrderUtils obj = new UserOrderUtils();
        int count = obj.queryUserOrderCount(map);
        String code = obj.getErrCode();
        obj.dispose();
        if (!code.equals(SysErr.CODE_SUCCESS)) {
            return XmlCodeParser.formatResultTips(false, code);
        }
        return XmlCodeParser.formatResultData(true, code, "\"" + count + "\"");
    }

    /**
     * 按时间段统计符合条件的订单数
     *
     * @param req
     * @param resp
     * @param p={"timeType":时间类型 W本周 M 本月 }
     * @param sid
     * @return add wzj by 2018/12/12
     */
    public String queryOrderCountByDatetime(HttpServletRequest req, HttpServletResponse resp, String p, String sid) {
        String timeType = JsonTool.getStrValue(p, "timeType", "W");
        String startTime = JsonTool.getStrValue(p, "startTime", null);
        if (StrTool.isBlankStr(timeType)) {
            return XmlCodeParser.formatResultTips(false, SysErr.SYS_PARAM_ERR);
        }

        if ("W".equals(timeType)) { //本周
            startTime = DateTimeTool.dateToDateString(DateTimeTool.incDay(new Date(), -7));
        } else if ("M".equals(timeType)) { //本月
            startTime = DateTimeTool.dateToDateString(DateTimeTool.incMonth(new Date(), -1));
        } else {
            return XmlCodeParser.formatResultTips(false, SysErr.SYS_PARAM_ERR);
        }

        String endTime = DateTimeTool.dateToDateString(new Date());

        UserOrderUtils obj = new UserOrderUtils();
        Map<String, Object> cdt = new HashMap<String, Object>();
        if (!StrTool.isBlankStr(startTime)) {
            cdt.put("startTime", startTime);
        }

        List<Statistics> rets = obj.queryOrderCount(cdt, "D");
        String err = obj.getErrCode();
        obj.dispose();
        if (!err.equals(SysErr.CODE_SUCCESS)) {
            return XmlCodeParser.formatResultTips(false, err);
        }

        return XmlCodeParser.formatResultData(true, err, StatistisTool.getLineDate(rets, startTime, endTime));
    }
}
